import 'package:FlutterStudy/utils/splash.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget with Splash{
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    hideScreen();
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('DraggableScrollableSheet Demo')),
        body: Stack( // 使用 Stack 将 sheet 覆盖在其他内容之上
          children: [
            // 背景内容（例如地图）
            Container(
              color: Colors.blueGrey[100],
              child: const Center(
                child: Text('Background Content', style: TextStyle(fontSize: 24)),
              ),
            ),
            // 可拖动滚动面板
            DraggableScrollableSheet(
              initialChildSize: 0.3, // 初始显示30%的高度
              minChildSize: 0.2,     // 最小可以拖到20%的高度
              maxChildSize: 0.8,     // 最大可以拖到80%的高度
              builder: (BuildContext context, ScrollController scrollController) {
                return Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(16),
                      topRight: Radius.circular(16),
                    ),
                    boxShadow: [
                      BoxShadow(
                        color: Colors.black.withOpacity(0.2),
                        blurRadius: 8,
                        offset: const Offset(0, -3),
                      ),
                    ],
                  ),
                  child: ListView.builder(
                    controller: scrollController, // 必须传递这个 controller！
                    itemCount: 25,
                    itemBuilder: (BuildContext context, int index) {
                      return ListTile(
                        title: Text('Item ${index + 1}'),
                        subtitle: Text('This is item number ${index + 1}'),
                      );
                    },
                  ),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
